// @/utils/i18n.ts
import { ref, watch } from 'vue';

// 定义语言消息类型接口
interface LangMessages {
  [key: string]: string | string[];
}

interface Messages {
  zh: LangMessages;
  en: LangMessages;
  jp: LangMessages;
}

// 国际化语言包数据
export const messages: Messages = {
  zh: {
    eyeControlCenter: "眼神控制中心",
    viaEyeMovement: "通过眼神移动实现键盘输入",
    systemStatus: "系统状态",
    cameraStatus: "摄像头状态",
    eyeTracking: "眼神追踪",
    inputMode: "输入模式",
    typingMode: "打字模式",
    eyeMode: "眼神模式",
    sensitivitySettings: "灵敏度设置",
    movementSensitivity: "移动灵敏度",
    blinkThreshold: "眨眼检测阈值",
    stopTracking: "停止追踪",
    startTracking: "开始追踪",
    myNotes: "我的笔记",
    myFavorites: "我的收藏",
    myFollows: "我的关注",
    myCoupons: "我的优惠券",
    mall: "商城",
    settings: "设置",
    personalInfo: "个人基础信息",
    privacySecurity: "隐私与安全",
    privacySettings: "隐私设置",
    notifications: "消息与提醒",
    terms: "协议与条款",
    about: "关于爱运动",
    language: "国际化语言",
    customerService: "客服中心",
    realNameAuth: "实名认证",
    logout: "退出登录",
    sportRecord: "运动记录",
    cumulativeTime: "累计时间",
    thisWeekData: "本周运动数据",
    today: "今日",
    weekOverview: "本周运动数据",
    followList: "我的关注",
    total: "共",
    noFollowedUsers: "暂无关注的用户",
    discoverPeople: "去社区发现更多有趣的人吧~",
    cancelFollow: "取消关注",
    followTime: "关注时间：",
    myFavoritesList: "我的收藏",
    noFavorites: "暂无收藏视频",
    collectVideos: "去视频页面收藏喜欢的内容吧~",
    removeFavorite: "移除",
    favoriteTime: "收藏时间：",
    myCouponsList: "我的优惠券",
    noAvailableCoupons: "暂无可用优惠券",
    noUsedCoupons: "暂无已使用优惠券",
    noExpiredCoupons: "暂无过期优惠券",
    getMoreCoupons: "去商城购物获取更多优惠券吧~",
    available: "可用",
    used: "已用",
    expired: "过期",
    minSpend: "满",
    yuan: "元可用",
    expires: "到期",
    from: "来源：",
    sportData: "运动数据",
    goToVideoDetail: "查看视频详情",
    confirmLogout: "确定要退出登录吗？",
    sendContent: "发送内容：",
    changeCover: "更换封面",
    uploading: "上传中...",
    days: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
    pleaseSelectImageFile: "请选择图片文件",
    imageSizeLimit: "图片大小不能超过5MB",
    back: "返回",
    authBenefits: "完成实名认证后可获得XXXX权益，也可找回你的账号或验证你账号的安全性。",
    authVoluntary: "你可以自主选择是否进行实名认证，未实名认证不影响你使用前述服务之外的其他服务。",
    realName: "真实姓名",
    enterName: "请输入姓名",
    idCardNumber: "身份证号码",
    enterIdCard: "请输入身份证号码",
    clickToShowIdCard: "点击图标显示号码",
    agreeAndVerify: "同意协议并进行人脸认证",
    faceInfoCollection: "除真实姓名及身份证号外，为核验你提交的信息的真实性，我们在必要时会收集你的人脸信息，收集及处理方式可在以下协议中查看",
    readAndAgree: "已阅读并同意",
    authAgreement: "实名认证服务相关协议",
    pleaseEnterIdCard: "请输入身份证号码",
    idCardLengthError: "身份证号码长度应为15位或18位",
    invalidIdCard: "请输入有效的身份证号码",
    pleaseEnterName: "请输入真实姓名",
    invalidName: "姓名格式无效，必须包含文字",
    nameTooShort: "姓名长度至少为2个字符",
    nameHasSpecialChars: "姓名不能包含特殊字符",
    saveFailed: "数据保存失败，请重试",
    authSuccess: "认证成功，正在跳转...",
    jumpFailed: "跳转失败，请重试",
    pleaseAgreeProtocol: "请勾选服务协议",
    pleaseCompleteInfo: "请完善姓名和身份证信息",
    loadFailed: "数据加载失败，请重试",
    aiFitnessAssistant: "AI 运动健身助手",
    welcomeMessage: "你好！我是基于硅基流动 AI 模型的运动健身助手，我能为你提供专业的健身建议和解答。有什么可以帮助你的吗？",
    send: "发送",
    processing: "处理中...",
    quickQuestion1: "如何制定适合我的运动计划？",
    quickQuestion2: "运动后肌肉酸痛怎么缓解？",
    quickQuestion3: "推荐一些初学者的健身动作",
    quickQuestion4: "每天应该运动多长时间？",
    commonQuestions: "常见问题",
    inputQuestionPlaceholder: "输入您的问题...",
    describeImagePlaceholder: "描述图片或提问...",
    uploadImage: "上传图片",
    previewImageAlt: "预览图片",
    removeImage: "移除图片",
    thinkingProcess: "思考过程",
    thinking: "思考中",
    sending: "发送中...",
    retry: "重试",
    disableStreaming: "关闭流式输出",
    enableStreaming: "开启流式输出",
    hideThinking: "隐藏思考过程",
    showThinking: "显示思考过程",
    undoTooltip: "回退到上一步",
    deleteTooltip: "删除最后一条消息",
    undoSuccess: "已回退到上一步",
    deleteSuccess: "已删除最后一条消息",
    imageTypeError: "仅支持 JPEG、PNG、GIF、WebP 格式的图片",
    imageSizeError: "图片大小不能超过 {size} MB",
    imageDimensionError: "图片尺寸过大，请选择较小的图片",
    imageFormatError: "图片格式不正确或已损坏",
    imageProcessError: "图片处理失败，请重试",
    analyzeImagePrompt: "请分析这张图片",
    systemPrompt: "你是一个专业的运动健身 AI 助手，请为用户提供科学、实用的健身建议。回答要专业且易于理解。如果用户上传了图片，请仔细分析图片内容并结合健身知识给出相关建议。",
    thinkingAnalyzeImage: "正在分析上传的图片...",
    thinkingIdentifyContent: "识别图片中的健身相关内容...",
    thinkingProvideAdvice: "结合专业知识提供建议...",
    thinkingAnalyzeQuestion: "分析用户问题的核心意图...",
    thinkingRetrieveKnowledge: "检索相关的健身知识...",
    thinkingOrganizeAnswer: "组织专业且易懂的回答...",
    thinkingStep1: "分析用户问题的核心意图和关键词...",
    thinkingStep2: "检索相关领域的专业知识...",
    thinkingStep3: "评估多种可能的回答方向...",
    thinkingStep4: "组织语言，确保回答专业且易于理解...",
    workoutPlanKeyword: "运动计划",
    thinkingPlan1: "考虑用户可能的健康状况和健身目标...",
    thinkingPlan2: "参考运动医学研究数据，确定合理的运动频率和强度建议...",
    muscleSorenessKeyword: "肌肉酸痛",
    thinkingSoreness1: "分析肌肉酸痛的生理机制和常见原因...",
    thinkingSoreness2: "评估不同缓解方法的有效性和适用场景...",
    beginnerKeyword: "初学者",
    exerciseKeyword: "健身动作",
    thinkingExercise1: "筛选适合初学者的基础动作，考虑安全性和有效性...",
    thinkingExercise2: "思考如何描述动作要领，确保用户能正确理解...",
    durationKeyword: "时间",
    thinkingDuration1: "参考国际运动医学组织的运动时长建议...",
    thinkingDuration2: "考虑不同强度运动的时间等效关系...",
    apiError: "API 调用错误",
    streamError: "无法获取响应流",
    maxRetriesReached: "已达到最大重试次数",
    requestCancelled: "请求已被取消",
    aiResponseError: "抱歉，AI 服务暂时不可用，请稍后再试。",
    retryImageMessage: "重试包含图片的消息",
    retryFailed: "重试失败",
    saveHistoryFailed: "保存聊天记录失败",
    loadHistoryFailed: "加载聊天记录失败",
    userImageAlt: "用户上传的图片",
    removeImageTooltip: "移除图片"
  },
  en: {
    eyeControlCenter: "Eye Control Center",
    viaEyeMovement: "Keyboard input via eye movement",
    systemStatus: "System Status",
    cameraStatus: "Camera Status",
    eyeTracking: "Eye Tracking",
    inputMode: "Input Mode",
    typingMode: "Typing Mode",
    eyeMode: "Eye Mode",
    sensitivitySettings: "Sensitivity Settings",
    movementSensitivity: "Movement Sensitivity",
    blinkThreshold: "Blink Threshold",
    stopTracking: "Stop Tracking",
    startTracking: "Start Tracking",
    myNotes: "My Notes",
    myFavorites: "My Favorites",
    myFollows: "My Follows",
    myCoupons: "My Coupons",
    mall: "Mall",
    settings: "Settings",
    personalInfo: "Personal Information",
    privacySecurity: "Privacy & Security",
    privacySettings: "Privacy Settings",
    notifications: "Messages & Notifications",
    terms: "Terms & Agreements",
    about: "About Sports App",
    language: "Language",
    customerService: "Customer Service",
    realNameAuth: "Real-name Authentication",
    logout: "Logout",
    sportRecord: "Sports Record",
    cumulativeTime: "Cumulative Time",
    thisWeekData: "This Week's Data",
    today: "Today",
    weekOverview: "Weekly Sports Data",
    followList: "My Follows",
    total: "Total",
    noFollowedUsers: "No followed users",
    discoverPeople: "Discover more interesting people in the community~",
    cancelFollow: "Unfollow",
    followTime: "Followed on: ",
    myFavoritesList: "My Favorites",
    noFavorites: "No favorite videos",
    collectVideos: "Go to video page to collect favorite content~",
    removeFavorite: "Remove",
    favoriteTime: "Collected on: ",
    myCouponsList: "My Coupons",
    noAvailableCoupons: "No available coupons",
    noUsedCoupons: "No used coupons",
    noExpiredCoupons: "No expired coupons",
    getMoreCoupons: "Get more coupons by shopping in the mall~",
    available: "Available",
    used: "Used",
    expired: "Expired",
    minSpend: "Min. spend ",
    yuan: " yuan",
    expires: "expires on",
    from: "From: ",
    sportData: "Sports Data",
    goToVideoDetail: "View Video Details",
    confirmLogout: "Are you sure to logout?",
    sendContent: "Send content: ",
    changeCover: "Change Cover",
    uploading: "Uploading...",
    days: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
    pleaseSelectImageFile: "Please select an image file",
    imageSizeLimit: "Image size cannot exceed 5MB",
    back: "Back",
    authBenefits: "After completing real-name authentication, you can get XXXX benefits, retrieve your account, or verify your account security.",
    authVoluntary: "You can choose whether to perform real-name authentication. Not completing it will not affect other services except the aforementioned ones.",
    realName: "Real Name",
    enterName: "Please enter your name",
    idCardNumber: "ID Card Number",
    enterIdCard: "Please enter ID card number",
    clickToShowIdCard: "Click icon to show number",
    agreeAndVerify: "Agree to terms and proceed with face verification",
    faceInfoCollection: "In addition to your real name and ID card number, we may collect your facial information when necessary to verify the authenticity of the information you submit. Please refer to the following agreements for collection and processing methods.",
    readAndAgree: "I have read and agree to the",
    authAgreement: "Real-Name Authentication Service Agreement",
    pleaseEnterIdCard: "Please enter ID card number",
    idCardLengthError: "ID card number must be 15 or 18 digits",
    invalidIdCard: "Please enter a valid ID card number",
    pleaseEnterName: "Please enter your real name",
    invalidName: "Invalid name format, must contain text",
    nameTooShort: "Name must be at least 2 characters",
    nameHasSpecialChars: "Name cannot contain special characters",
    saveFailed: "Failed to save data, please try again",
    authSuccess: "Authentication successful, redirecting...",
    jumpFailed: "Jump failed, please try again",
    pleaseAgreeProtocol: "Please check the service agreement",
    pleaseCompleteInfo: "Please complete name and ID card information",
    loadFailed: "Failed to load data, please try again",
    aiFitnessAssistant: "AI Fitness Assistant",
    welcomeMessage: "Hello! I'm a fitness AI assistant based on Silicon Flow AI model. I can provide professional fitness advice and answers. How can I help you?",
    send: "Send",
    processing: "Processing...",
    quickQuestion1: "How to create a suitable workout plan for me?",
    quickQuestion2: "How to relieve muscle soreness after exercise?",
    quickQuestion3: "Recommend some beginner-friendly fitness exercises",
    quickQuestion4: "How long should I exercise each day?",
    commonQuestions: "Common Questions",
    inputQuestionPlaceholder: "Enter your question...",
    describeImagePlaceholder: "Describe the image or ask a question...",
    uploadImage: "Upload image",
    previewImageAlt: "Preview image",
    removeImage: "Remove image",
    thinkingProcess: "Thinking Process",
    thinking: "Thinking",
    sending: "Sending...",
    retry: "Retry",
    disableStreaming: "Disable streaming output",
    enableStreaming: "Enable streaming output",
    hideThinking: "Hide thinking process",
    showThinking: "Show thinking process",
    undoTooltip: "Undo to previous step",
    deleteTooltip: "Delete last message",
    undoSuccess: "Undone to previous step",
    deleteSuccess: "Last message deleted",
    imageTypeError: "Only JPEG, PNG, GIF, WebP formats are supported",
    imageSizeError: "Image size cannot exceed {size} MB",
    imageDimensionError: "Image dimensions are too large, please choose a smaller image",
    imageFormatError: "Image format is incorrect or corrupted",
    imageProcessError: "Failed to process image, please try again",
    analyzeImagePrompt: "Please analyze this image",
    systemPrompt: "You are a professional fitness AI assistant. Provide scientific and practical fitness advice to users. Answers should be professional yet easy to understand. If users upload images, carefully analyze the content and provide relevant advice based on fitness knowledge.",
    thinkingAnalyzeImage: "Analyzing uploaded image...",
    thinkingIdentifyContent: "Identifying fitness-related content in the image...",
    thinkingProvideAdvice: "Providing advice based on professional knowledge...",
    thinkingAnalyzeQuestion: "Analyzing the core intent of the user's question...",
    thinkingRetrieveKnowledge: "Retrieving relevant fitness knowledge...",
    thinkingOrganizeAnswer: "Organizing a professional and understandable answer...",
    thinkingStep1: "Analyzing the core intent and keywords of the user's question...",
    thinkingStep2: "Retrieving professional knowledge in related fields...",
    thinkingStep3: "Evaluating multiple possible answer directions...",
    thinkingStep4: "Organizing language to ensure professional and understandable answers...",
    workoutPlanKeyword: "workout plan",
    thinkingPlan1: "Considering the user's possible health status and fitness goals...",
    thinkingPlan2: "Referencing sports medicine research data to determine reasonable exercise frequency and intensity recommendations...",
    muscleSorenessKeyword: "muscle soreness",
    thinkingSoreness1: "Analyzing the physiological mechanisms and common causes of muscle soreness...",
    thinkingSoreness2: "Evaluating the effectiveness and applicable scenarios of different relief methods...",
    beginnerKeyword: "beginner",
    exerciseKeyword: "fitness exercise",
    thinkingExercise1: "Selecting basic exercises suitable for beginners, considering safety and effectiveness...",
    thinkingExercise2: "Figuring out how to describe exercise essentials to ensure users can understand correctly...",
    durationKeyword: "time",
    thinkingDuration1: "Referencing exercise duration recommendations from international sports medicine organizations...",
    thinkingDuration2: "Considering time equivalence relationships for different intensity exercises...",
    apiError: "API error",
    streamError: "Unable to get response stream",
    maxRetriesReached: "Maximum retries reached",
    requestCancelled: "Request cancelled",
    aiResponseError: "Sorry, AI service is temporarily unavailable. Please try again later.",
    retryImageMessage: "Retrying message with image",
    retryFailed: "Retry failed",
    saveHistoryFailed: "Failed to save chat history",
    loadHistoryFailed: "Failed to load chat history",
    userImageAlt: "User uploaded image",
    removeImageTooltip: "Remove image"
  },
  jp: {
    eyeControlCenter: "アイコントロールセンター",
    viaEyeMovement: "目の動きでキーボード入力を実現",
    systemStatus: "システム状態",
    cameraStatus: "カメラ状態",
    eyeTracking: "アイトラッキング",
    inputMode: "入力モード",
    typingMode: "タイピングモード",
    eyeMode: "アイモード",
    sensitivitySettings: "感度設定",
    movementSensitivity: "移動感度",
    blinkThreshold: "瞬き検出しきい値",
    stopTracking: "追跡を停止",
    startTracking: "追跡を開始",
    myNotes: "マイノート",
    myFavorites: "お気に入り",
    myFollows: "フォロー中",
    myCoupons: "クーポン",
    mall: "ショッピングモール",
    settings: "設定",
    personalInfo: "個人基本情報",
    privacySecurity: "プライバシーとセキュリティ",
    privacySettings: "プライバシー設定",
    notifications: "メッセージと通知",
    terms: "利用規約",
    about: "スポーツアプリについて",
    language: "言語設定",
    customerService: "カスタマーサービス",
    realNameAuth: "実名認証",
    logout: "ログアウト",
    sportRecord: "運動記録",
    cumulativeTime: "累計時間",
    thisWeekData: "今週のデータ",
    today: "今日",
    weekOverview: "週間運動データ",
    followList: "フォロー一覧",
    total: "合計",
    noFollowedUsers: "フォローしているユーザーはいません",
    discoverPeople: "コミュニティでもっと多くの人を発見しよう~",
    cancelFollow: "フォロー解除",
    followTime: "フォロー日時: ",
    myFavoritesList: "お気に入り一覧",
    noFavorites: "お気に入りの動画はありません",
    collectVideos: "動画ページでお気に入りのコンテンツを収集しましょう~",
    removeFavorite: "削除",
    favoriteTime: "収集日時: ",
    myCouponsList: "クーポン一覧",
    noAvailableCoupons: "利用可能なクーポンはありません",
    noUsedCoupons: "使用済みのクーポンはありません",
    noExpiredCoupons: "期限切れのクーポンはありません",
    getMoreCoupons: "モールで買い物をして、さらに多くのクーポンを獲得しましょう~",
    available: "利用可能",
    used: "使用済み",
    expired: "期限切れ",
    minSpend: "最低購入額 ",
    yuan: "元以上",
    expires: "有効期限",
    from: "発行元: ",
    sportData: "運動データ",
    goToVideoDetail: "動画詳細を表示",
    confirmLogout: "ログアウトしてもよろしいですか？",
    sendContent: "送信内容: ",
    changeCover: "カバーを変更",
    uploading: "アップロード中...",
    days: ["月", "火", "水", "木", "金", "土", "日"],
    pleaseSelectImageFile: "画像ファイルを選択してください",
    imageSizeLimit: "画像サイズは5MBを超えることができません",
    back: "戻る",
    authBenefits: "実名認証を完了するとXXXXの特典を受けることができ、アカウントを回復したり、アカウントの安全性を確認したりすることもできます。",
    authVoluntary: "実名認証を行うかどうかは自主的に選択できます。未認証の場合、上記サービス以外の他のサービスの使用に影響はありません。",
    realName: "実名",
    enterName: "名前を入力してください",
    idCardNumber: "身分証明書番号",
    enterIdCard: "身分証明書番号を入力してください",
    clickToShowIdCard: "アイコンをクリックして番号を表示",
    agreeAndVerify: "同意して顔認証を行う",
    faceInfoCollection: "実名と身分証明書番号に加え、必要に応じて顔情報を収集し、提出した情報の真実性を確認する場合があります。収集と処理方法については以下の協定を参照してください。",
    readAndAgree: "読み込んで同意しました",
    authAgreement: "実名認証サービス関連協定",
    pleaseEnterIdCard: "身分証明書番号を入力してください",
    idCardLengthError: "身分証明書番号は15桁または18桁でなければなりません",
    invalidIdCard: "有効な身分証明書番号を入力してください",
    pleaseEnterName: "実名を入力してください",
    invalidName: "名前の形式が無効です。文字を含める必要があります",
    nameTooShort: "名前は少なくとも2文字以上でなければなりません",
    nameHasSpecialChars: "名前に特殊文字を含めることはできません",
    saveFailed: "データの保存に失敗しました。再試行してください",
    authSuccess: "認証が成功しました。ジャンプ中...",
    jumpFailed: "ジャンプに失敗しました。再試行してください",
    pleaseAgreeProtocol: "サービス契約にチェックを入れてください",
    pleaseCompleteInfo: "名前と身分証明書情報を入力してください",
    loadFailed: "データの読み込みに失敗しました。再試行してください",
    aiFitnessAssistant: "AI 運動フィットネスアシスタント",
    welcomeMessage: "こんにちは！私はシリコンフロー AI モデルに基づく運動フィットネスアシスタントです。専門的なフィットネスアドバイスと回答を提供できます。どのようなご協力が必要ですか？",
    send: "送信",
    processing: "処理中...",
    quickQuestion1: "自分に合った運動計画を作成するにはどうすればよいですか？",
    quickQuestion2: "運動後の筋肉痛をどのように緩和すればよいですか？",
    quickQuestion3: "初心者向けのフィットネス動作を推奨してください",
    quickQuestion4: "毎日どれくらい運動すればよいですか？",
    commonQuestions: "よくある質問",
    inputQuestionPlaceholder: "質問を入力してください...",
    describeImagePlaceholder: "画像を説明するか質問してください...",
    uploadImage: "画像をアップロード",
    previewImageAlt: "画像プレビュー",
    removeImage: "画像を削除",
    thinkingProcess: "思考過程",
    thinking: "思考中",
    sending: "送信中...",
    retry: "再試行",
    disableStreaming: "ストリーミング出力を無効にする",
    enableStreaming: "ストリーミング出力を有効にする",
    hideThinking: "思考過程を非表示",
    showThinking: "思考過程を表示",
    undoTooltip: "前のステップに戻る",
    deleteTooltip: "最後のメッセージを削除",
    undoSuccess: "前のステップに戻りました",
    deleteSuccess: "最後のメッセージを削除しました",
    imageTypeError: "JPEG、PNG、GIF、WebP 形式のみサポートされています",
    imageSizeError: "画像サイズは {size} MB を超えることはできません",
    imageDimensionError: "画像寸法が大きすぎます。小さい画像を選択してください",
    imageFormatError: "画像形式が正しくないか破損しています",
    imageProcessError: "画像の処理に失敗しました。再試行してください",
    analyzeImagePrompt: "この画像を分析してください",
    systemPrompt: "あなたは専門的な運動フィットネス AI アシスタントです。ユーザーに科学的で実用的なフィットネスアドバイスを提供してください。回答は専門的で理解しやすいものにしてください。ユーザーが画像をアップロードした場合は、画像内容を詳細に分析し、フィットネス知識を組み合わせて関連するアドバイスを提供してください。",
    thinkingAnalyzeImage: "アップロードされた画像を分析中...",
    thinkingIdentifyContent: "画像内のフィットネス関連コンテンツを識別中...",
    thinkingProvideAdvice: "専門知識に基づいてアドバイスを提供中...",
    thinkingAnalyzeQuestion: "ユーザーの質問の核心意図を分析中...",
    thinkingRetrieveKnowledge: "関連するフィットネス知識を検索中...",
    thinkingOrganizeAnswer: "専門的で理解しやすい回答を整理中...",
    thinkingStep1: "ユーザーの質問の核心意図とキーワードを分析中...",
    thinkingStep2: "関連分野の専門知識を検索中...",
    thinkingStep3: "複数の可能な回答方向を評価中...",
    thinkingStep4: "回答が専門的かつ理解しやすいように言語を整理中...",
    workoutPlanKeyword: "運動計画",
    thinkingPlan1: "ユーザーの可能性のある健康状態とフィットネス目標を考慮中...",
    thinkingPlan2: "運動医学研究データを参照して、合理的な運動頻度と強度の推奨を決定中...",
    muscleSorenessKeyword: "筋肉痛",
    thinkingSoreness1: "筋肉痛の生理的メカニズムと一般的な原因を分析中...",
    thinkingSoreness2: "さまざまな緩和方法の有効性と適用シナリオを評価中...",
    beginnerKeyword: "初心者",
    exerciseKeyword: "フィットネス動作",
    thinkingExercise1: "安全性と有効性を考慮して、初心者に適した基本動作を選別中...",
    thinkingExercise2: "ユーザーが正しく理解できるように動作の要領を説明する方法を考え中...",
    durationKeyword: "時間",
    thinkingDuration1: "国際運動医学組織の運動時間推奨を参照中...",
    thinkingDuration2: "強度の異なる運動の時間的等価関係を考慮中...",
    apiError: "API エラー",
    streamError: "応答ストリームを取得できません",
    maxRetriesReached: "最大再試行回数に達しました",
    requestCancelled: "リクエストがキャンセルされました",
    aiResponseError: "申し訳ありませんが、AI サービスは一時的に利用できません。後で再試行してください。",
    retryImageMessage: "画像付きメッセージを再試行中",
    retryFailed: "再試行に失敗しました",
    saveHistoryFailed: "チャット履歴の保存に失敗しました",
    loadHistoryFailed: "チャット履歴の読み込みに失敗しました",
    userImageAlt: "ユーザーがアップロードした画像",
    removeImageTooltip: "画像を削除"
  }
};

// 支持的语言列表
export const supportedLangs = [
  { code: 'zh', name: '中文' },
  { code: 'en', name: 'English' },
  { code: 'jp', name: '日本語' }
];

// 国际化 composable
export function useI18n() {
  // 从本地存储读取初始语言
  const currentLang = ref(localStorage.getItem('appLang') || 'zh');

  // 监听语言变化，保存到本地存储
  watch(currentLang, (newLang) => {
    localStorage.setItem('appLang', newLang);
  });

  // 切换语言
  const changeLanguage = (lang: string) => {
    if (supportedLangs.some(l => l.code === lang)) {
      currentLang.value = lang;
    }
  };

  // 获取翻译文本
  const t = (key: string): string => {
    // 支持通过点符号访问嵌套属性，如 "days.0"
    const keys = key.split('.');
    let value: any = messages[currentLang.value as keyof typeof messages];

    for (const k of keys) {
      if (value && typeof value === 'object' && k in value) {
        value = value[k];
      } else {
        // 如果找不到对应的翻译，返回原始key
        return key;
      }
    }

    return typeof value === 'string' ? value : key;
  };

  return {
    currentLang,
    changeLanguage,
    t,
    supportedLangs
  };
}